<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="common/include :: header('修改养修服务预约')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-edit" th:object="${appointment}">
        <input id="appointmentId" name="id" type="hidden" th:field="*{id}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">客户姓名：</label>
            <div class="col-sm-8">
                <input class="form-control" th:field="*{customerName}" type="text" name="customerName" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">客户联系方式：</label>
            <div class="col-sm-8">
                <input class="form-control" th:field="*{customerPhone}" type="text" name="customerPhone" required>
            </div>
        </div>

		<div class="form-group">
			<label class="col-sm-3 control-label is-required">预约时间：</label>
			<div class="col-sm-8">
				<div class="input-group date">
					<input name="appointmentTime" class="form-control" th:field="*{appointmentTime}"
						   placeholder="yyyy-MM-dd HH:mm" type="text"
						   required>
					<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
				</div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label is-required">车牌号码：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" th:field="*{licensePlate}" name="licensePlate" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label is-required">汽车类型：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text"  th:field="*{carSeries}" name="carSeries" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label is-required">服务类型：</label>
			<div class="col-sm-8">
				<select name="serviceType" class="form-control m-b" th:field="*{serviceType}"
						th:with="type=${@dict.getType('cmi_service_type')}"
						required>
					<option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
				</select>
			</div>
		</div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注信息：</label>
            <div class="col-sm-8">
                <textarea name="info" class="form-control" th:field="*{info}"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="common/include :: footer"/>
<th:block th:include="common/include :: datetimepicker"/>
<script type="text/javascript">
    var prefix = ctx + "/business/appointment";

    /*
            $("#form-post-edit").validate({
                onkeyup: false,
                rules:{
                    name:{
                        remote: {
                            type: "post",
                            dataType: "json",
                            data: {
                                "id": function() {
                                    return $("input[name='id']").val();
                                },
                                "name" : function() {
                                    return $.common.trim($("#appointmentName").val());
                                }
                            },
                            dataFilter: function(data, type) {
                                return $.validate.unique(data);
                            }
                        }
                    },
                    phone:{
                        remote: {
                            type: "post",
                            dataType: "json",
                            data: {
                                "id": function() {
                                    return $("input[name='id']").val();
                                },
                                "phone" : function() {
                                    return $.common.trim($("#appointmentPhone").val());
                                }
                            },
                            dataFilter: function(data, type) {
                                return $.validate.unique(data);
                            }
                        }
                    },
                    age:{
                        remote: {
                            type: "post",
                            dataType: "json",
                            data: {
                                "id": function() {
                                    return $("input[name='id']").val();
                                },
                                "age" : function() {
                                    return $.common.trim($("#appointmentAge").val());
                                }
                            },
                            dataFilter: function(data, type) {
                                return $.validate.unique(data);
                            }
                        }
                    },
                },
                messages: {
                    "name": {
                        remote: "服务项名称已经存在"
                    }
                },
                focusCleanup: true
            });
    */

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
        }
    }

	$("#form-appointment-add").validate({
		rules: {
			customerPhone: {
				isPhone: true
			}
		},
		messages: {
			"customerPhone": "手机格式不正确"
		},
		focusCleanup: true
	});

	$("input[name='appointmentTime']").datetimepicker({
		format: "yyyy-mm-dd hh:ii",
		startDate: new Date(),
		autoclose: true
	});
</script>
</body>
</html>
